//
//  GoodsOrderDetailsSecondCell.m
//  EasyToTesco2.0
//
//  Created by 杨森 on 16/9/9.
//  Copyright © 2016年 EasyToTesco. All rights reserved.
//

#import "GoodsOrderDetailsSecondCell.h"

@implementation GoodsOrderDetailsSecondCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupView];
    }
    return self;
}

- (void)setupView
{
    CGFloat margin = 10;
    
    NSInteger fontSize;
    if (iPhone5) {
        fontSize = 11;
    }else{
        fontSize = 12;
    }
    
    self.goodsImg = [[UIImageView alloc] init];
    [self.contentView addSubview:_goodsImg];
    _goodsImg.frame = CGRectMake(margin,margin,80,80);
    
    self.goodsNameLabel = [[UILabel alloc] init];
    _goodsNameLabel.font = FONT(fontSize);
    _goodsNameLabel.numberOfLines = 0;
    [self.contentView addSubview:_goodsNameLabel];
    
    self.guigeLabel = [[UILabel alloc] init];
    _guigeLabel.font = FONT(fontSize);
    _guigeLabel.numberOfLines = 0;
    _guigeLabel.textColor = [UIColor grayColor];
    [self.contentView addSubview:_guigeLabel];
    
    _priceLabel = [[UILabel alloc] init];
    _priceLabel.font = FONT(fontSize);
    _priceLabel.textAlignment = NSTextAlignmentRight;
    _priceLabel.textColor = DEFAULT_COLOR;
    [self.contentView addSubview:_priceLabel];
    
    _numLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_numLabel];
    _numLabel.textColor = RGB(90,90,90);
    _numLabel.textAlignment = NSTextAlignmentRight;
    _numLabel.font = FONT(fontSize);
    
    //分割线
    UIView *lineView = [[UIView alloc] init];
    lineView.backgroundColor = [UIColor blackColor];
    lineView.alpha = 0.1;
    [self.contentView addSubview:lineView];
    
    UILabel *kuaidiLabel = [[UILabel alloc] init];
    kuaidiLabel.font = FONT(13);
    kuaidiLabel.text = @"快递运费:";
    kuaidiLabel.textColor = RGB(90,90,90);
    [self.contentView addSubview:kuaidiLabel];
    self.kuaidiLabel = kuaidiLabel;
    
    _freeLabel = [[UILabel alloc] init];
    _freeLabel.font = FONT(13);
    _freeLabel.text = @"包邮";
    _freeLabel.textColor = RGB(90,90,90);
    [self.contentView addSubview:_freeLabel];
    
    //分割线
    UIView *lineView1 = [[UIView alloc] init];
    lineView1.backgroundColor = [UIColor blackColor];
    lineView1.alpha = 0.1;
    [self.contentView addSubview:lineView1];
    
    UILabel *tempLabel = [[UILabel alloc] init];
    tempLabel.font = FONT(13);
    tempLabel.text = @"价格合计:";
    tempLabel.textColor = RGB(90,90,90);
    [self.contentView addSubview:tempLabel];
    
    _totalLabel = [[UILabel alloc] init];
    _totalLabel.font = FONT(13);
    _totalLabel.textColor = RGB(90,90,90);
    [self.contentView addSubview:_totalLabel];
    
    //分割线
//    UIView *lineView2 = [[UIView alloc] init];
//    lineView2.backgroundColor = [UIColor blackColor];
//    lineView2.alpha = 0.1;
//    [self.contentView addSubview:lineView2];
    
    [_goodsNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(_goodsImg.mas_top).offset(2);
        make.left.equalTo(_goodsImg.mas_right).offset(margin);
        make.width.mas_equalTo(WIDTH - _goodsImg.width - margin *3 - 60);
    }];
    
    [_guigeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(_goodsNameLabel.mas_bottom).offset(margin/2);
        make.left.equalTo(_goodsNameLabel.mas_left);
        make.width.equalTo(_goodsNameLabel.mas_width);
    }];
    
    [_priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(_goodsNameLabel.mas_top);
        make.right.equalTo(self.mas_right).offset(-margin);
        make.width.mas_equalTo(60);
    }];
    
    [_numLabel mas_makeConstraints:^(MASConstraintMaker *make) {
    
         make.top.equalTo(_guigeLabel.mas_top);
         make.right.equalTo(_priceLabel.mas_right);
        make.width.mas_equalTo(60);
    }];
    
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(_goodsImg.mas_bottom).offset(margin);
        make.width.mas_equalTo(WIDTH-20);
        make.left.equalTo(_goodsImg.mas_left);
        make.height.mas_equalTo(0.5);
        
    }];
    
    [kuaidiLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(lineView.mas_bottom).offset(margin);
        make.left.equalTo(_goodsImg.mas_left);
    }];
    
    [_freeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(lineView.mas_bottom).offset(margin);
        make.right.equalTo(_priceLabel.mas_right);
    }];
    
    [lineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(kuaidiLabel.mas_bottom).offset(margin);
        make.width.mas_equalTo(WIDTH-20);
        make.left.equalTo(kuaidiLabel.mas_left);
        make.height.mas_equalTo(0.5);
        
    }];
    
    [tempLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(lineView1.mas_bottom).offset(margin);
        make.left.equalTo(_goodsImg.mas_left);
    }];
    
    [_totalLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(lineView1.mas_bottom).offset(margin);
        make.right.equalTo(_priceLabel.mas_right);
    }];
    
//    [lineView2 mas_makeConstraints:^(MASConstraintMaker *make) {
//        
//        make.top.equalTo(tempLabel.mas_bottom).offset(margin);
//        make.width.mas_equalTo(WIDTH-20);
//        make.left.equalTo(kuaidiLabel.mas_left);
//        make.height.mas_equalTo(0.5);
//        
//    }];
    
}

@end
